package com.wcy.util;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

public class PasswordUtil {
    private static final BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();

    public static boolean verifyPassword(String password, String encodedPassword) {
        return encoder.matches(password, encodedPassword);
    }

    public static String encodePassword(String password) {
        return encoder.encode(password);
    }
    public static boolean isBCryptEncoded(String encodedPassword) {
        String regex = "^\\$2[aby]\\$\\d{2}\\$[./A-Za-z0-9]{53}$";
        return encodedPassword != null && encodedPassword.matches(regex);
    }
}
